#include("../layout.html")
#@layout("讨论设置")

#define body()
<h1>讨论设置</h1>

<div class="layui-fluid">
	<form class="layui-form" action="/admin/option/discussion" method="post">
		<div class="layui-form-item">
    		<label class="layui-form-label">默认文章设置</label>
    		<div class="layui-input-block">
    			<input type="checkbox" name="default_pingback_flag" id="default_pingback_flag" data="#(default_pingback_flag??)" value="1" title="尝试通知文章中链接的博客" lay-skin="primary"> 
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="checkbox" name="default_ping_status" id="default_ping_status" data="#(default_ping_status??)" value="open" title="允许其他博客发送链接通知（pingback和trackback）到新文章" lay-skin="primary"> 
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="checkbox" name="default_comment_status" id="default_comment_status" data="#(default_comment_status??)" value="open" title="允许他人在新文章上发表评论" lay-skin="primary"> 
   	 		</div>
   	 		<div class="layui-input-block">
   	 			<p class="description">(这些设置可被具体的文章设置所覆盖。)</p>
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<label class="layui-form-label">其它评论设置</label>
    		<div class="layui-input-block">
    			<input type="checkbox" name="require_name_email" id="require_name_email" data="#(require_name_email??)" value="1" title="评论作者必须填入姓名和电子邮件地址" lay-skin="primary"> 
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="checkbox" name="comment_registration" id="comment_registration" data="#(comment_registration??)" value="1" title="用户必须注册并登录才可以发表评论" lay-skin="primary"> 
   	 		</div>
   	 		<div class="layui-input-block">
   	 			<div class="layui-inline" style="margin-right: 0;">
    				<input type="checkbox" name="close_comments_for_old_posts" id="close_comments_for_old_posts" data="#(close_comments_for_old_posts??)" value="1" title="自动关闭发布" lay-skin="primary">
    			</div>
    			<div class="layui-inline" style="width:80px;margin-top: 10px;">
    				<input type="number" name="close_comments_days_old" id="close_comments_days_old" value="#(close_comments_days_old??)" class="layui-input" style="height:30px;">
    			</div>
    			<div class="layui-inline" style="margin-top: 10px;">
    				天后的文章上的评论功能
    			</div>
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="checkbox" name="show_comments_cookies_opt_in" id="show_comments_cookies_opt_in" data="#(show_comments_cookies_opt_in??)" value="1" title="显示使用评论cookies的复选框" lay-skin="primary"> 
   	 		</div>
   	 		<div class="layui-input-block">
   	 			<div class="layui-inline" style="margin-right: 0;">
    				<input type="checkbox" name="thread_comments" id="thread_comments" data="#(thread_comments??)" value="1" title="启用评论嵌套，最多嵌套" lay-skin="primary">
    			</div>
    			<div class="layui-inline" style="width:80px;margin-top:10px;">
    				<select name="thread_comments_depth" id="thread_comments_depth" data="#(thread_comments_depth??)">
    					<option value="2">2</option>
    					<option value="3">3</option>
    					<option value="4">4</option>
    					<option value="5">5</option>
    					<option value="6">6</option>
    					<option value="7">7</option>
    					<option value="8">8</option>
    					<option value="9">9</option>
    					<option value="10">10</option>
    				</select>
    			</div>
    			<div class="layui-inline" style="margin-top: 10px;">
    				层
    			</div>
   	 		</div>
   	 		<div class="layui-input-block">
   	 			<div class="layui-inline" style="margin-right: 0;">
    				<input type="checkbox" name="page_comments" id="page_comments" data="#(page_comments??)" value="1" title="分页显示评论，每页显示" lay-skin="primary"> 
    			</div>
    			<div class="layui-inline" style="width:80px;margin-top:10px;">
    				<input type="number" name="comments_per_page" id="comments_per_page" value="#(comments_per_page??)" class="layui-input" style="height:30px;">
    			</div>
    			<div class="layui-inline" style="margin-top: 10px;">
    			条评论，默认显示
    			</div>
    			<div class="layui-inline" style="width:80px;margin-top:10px;">
    				<select name="default_comments_page" id="default_comments_page" data="#(default_comments_page??)">
    					<option value="newest" selected="selected">最后</option>
    					<option value="oldest">最前</option>
    				</select>
    			</div>
    			<div class="layui-inline" style="margin-top: 10px;">
    			一页
    			</div>
   	 		</div>
   	 		<div class="layui-input-block">
   	 			在每个页面顶部显示
   	 			<div class="layui-inline" style="width:80px;">
    				<select name="comment_order" id="comment_order" data="#(comment_order??)">
    					<option value="asc" selected="selected">旧的</option>
    					<option value="desc">新的</option>
    				</select>
    			</div>
				评论
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<label class="layui-form-label">发送电子邮件通知我</label>
    		<div class="layui-input-block">
    			<input type="checkbox" name="comments_notify" id="comments_notify" data="#(comments_notify??)" value="1" title="有人发表评论时" lay-skin="primary"> 
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="checkbox" name="moderation_notify" id="moderation_notify" data="#(moderation_notify??)" value="1" title="有评论等待审核时" lay-skin="primary"> 
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<label class="layui-form-label">在评论显示之前</label>
    		<div class="layui-input-block">
    			<input type="checkbox" name="comment_moderation"  id="comment_moderation" data="#(comment_moderation??)" value="1" title="评论必须经人工批准" lay-skin="primary"> 
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="checkbox" name="comment_whitelist" id="comment_whitelist" data="#(comment_whitelist??)" value="1" title="评论者先前须有评论通过了审核" lay-skin="primary"> 
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<label class="layui-form-label">评论审核</label>
    		<div class="layui-input-block">
    			当某条评论包含超过
    			<div class="layui-inline" style="width:80px;">
    				<input type="number" name="comment_max_links" id="comment_max_links" value="#(comment_max_links??)" class="layui-input" style="height:30px;">
    			</div>
    			个超链接时，将其放入等待审队列。（垃圾评论通常含有许多超链接。）
   	 		</div>
   	 		<div class="layui-input-block">
    			当评论的内容、姓名、URL、电邮或IP中包含以下文字，它将被设定为
    			<a href="edit-comments.php?comment_status=moderated">待审核</a>
    			。每行输入一个词或IP地址。它也会在单词内部进行比对，所以“press”将会匹配“WordPress”。
   	 		</div>
   	 		<div class="layui-input-block">
    			<textarea name="moderation_keys" id="moderation_keys" placeholder="" class="layui-textarea">#(moderation_keys??)</textarea>
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<label class="layui-form-label">评论黑名单</label>
    		<div class="layui-input-block">
    			当评论的内容、姓名、URL、电邮或IP中包含以下文字，它将被移入回收站。每行输入一个词或IP地址。它也会在单词内部进行比对，所以“press”将会匹配“WordPress”。
   	 		</div>
   	 		<div class="layui-input-block">
    			<textarea name="blacklist_keys" id="blacklist_keys" placeholder="" class="layui-textarea">#(blacklist_keys??)</textarea>
   	 		</div>
    	</div>
    	
    	<h2 class="title">头像</h2>
    	<p>头像是您在各个博客见通用的图像。在每个启用了头像功能的站点上，它将显示在您的名字旁边。在这里您可以启用您站点上的读者评论头像显示功能。</p>
    	
    	<div class="layui-form-item">
    		<label class="layui-form-label">头像显示</label>
    		<div class="layui-input-block">
    			<input type="checkbox" name="show_avatars" id="show_avatars" data="#(show_avatars??)" value="1" title="显示头像" lay-skin="primary"> 
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<input type="hidden" id="avatar_rating" value="#(avatar_rating??)"/>
    		<label class="layui-form-label">最高等级</label>
    		<div class="layui-input-block">
    			<input type="radio" name="avatar_rating" value="G" title="G —— 适合任何年龄的访客查看" checked="checked">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="avatar_rating" value="PG" title="PG —— 可能有争议的头像，只适合13岁以上读者查看">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="avatar_rating" value="R" title="R —— 成人级，只适合17岁以上成人查看">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="avatar_rating" value="X" title="X —— 最高等级，不适合大多数人查看">
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<input type="hidden" id="avatar_default" value="#(avatar_default??)"/>
    		<label class="layui-form-label">默认头像</label>
    		<div class="layui-input-block">
    			如用户没有自定义头像，您可以显示一个通用标志或用他们的电子邮件地址生成一个。
    		</div>
    		<div class="layui-input-block">
    			<input type="radio" name="avatar_default" value="mystery" title="神秘人士" checked="checked">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="avatar_default" value="blank" title="空白">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="avatar_default" value="gravatar_default" title="Gravatar标志">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="avatar_default" value="identicon" title="抽象图形（自动生成）">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="avatar_default" value="wavatar" title="Wavatar（自动生成）">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="avatar_default" value="monsterid" title="小怪物（自动生成）">
   	 		</div>
   	 		<div class="layui-input-block">
    			<input type="radio" name="avatar_default" value="avatar_retro" title="复古（自动生成）">
   	 		</div>
    	</div>
    	<div class="layui-form-item">
    		<button type="submit" lay-submit lay-filter="*" class="layui-btn layui-btn-sm">保存更改</button>
    	</div>
    </form>
</div>
#end

#define foot()
<script>
layui.cache.page = 'option';
layui.use('tbynet', function(){
	var $ = layui.$
	,form = layui.form
	,tbynet = layui.tbynet;
	
	//checkbox
	if(1 == $('#default_pingback_flag').attr('data')) {
		$('#default_pingback_flag').prop('checked', true);
	} else {
		$('#default_pingback_flag').prop('checked', false);
	}
	if('open' == $('#default_ping_status').attr('data')) {
		$('#default_ping_status').prop('checked', true);
	} else {
		$('#default_ping_status').prop('checked', false);
	}
	if('open' == $('#default_comment_status').attr('data')) {
		$('#default_comment_status').prop('checked', true);
	} else {
		$('#default_comment_status').prop('checked', false);
	}
	if(1 == $('#require_name_email').attr('data')) {
		$('#require_name_email').prop('checked', true);
	} else {
		$('#require_name_email').prop('checked', false);
	}
	if(1 == $('#comment_registration').attr('data')) {
		$('#comment_registration').prop('checked', true);
	} else {
		$('#comment_registration').prop('checked', false);
	}
	if(1 == $('#close_comments_for_old_posts').attr('data')) {
		$('#close_comments_for_old_posts').prop('checked', true);
	} else {
		$('#close_comments_for_old_posts').prop('checked', false);
	}
	if(1 == $('#show_comments_cookies_opt_in').attr('data')) {
		$('#show_comments_cookies_opt_in').prop('checked', true);
	} else {
		$('#show_comments_cookies_opt_in').prop('checked', false);
	}
	if(1 == $('#thread_comments').attr('data')) {
		$('#thread_comments').prop('checked', true);
	} else {
		$('#thread_comments').prop('checked', false);
	}
	if(1 == $('#page_comments').attr('data')) {
		$('#page_comments').prop('checked', true);
	} else {
		$('#page_comments').prop('checked', false);
	}
	if(1 == $('#comments_per_page').attr('data')) {
		$('#comments_per_page').prop('checked', true);
	} else {
		$('#comments_per_page').prop('checked', false);
	}
	if(1 == $('#comments_notify').attr('data')) {
		$('#comments_notify').prop('checked', true);
	} else {
		$('#comments_notify').prop('checked', false);
	}
	if(1 == $('#moderation_notify').attr('data')) {
		$('#moderation_notify').prop('checked', true);
	} else {
		$('#moderation_notify').prop('checked', false);
	}
	if(1 == $('#comment_moderation').attr('data')) {
		$('#comment_moderation').prop('checked', true);
	} else {
		$('#comment_moderation').prop('checked', false);
	}
	if(1 == $('#comment_whitelist').attr('data')) {
		$('#comment_whitelist').prop('checked', true);
	} else {
		$('#comment_whitelist').prop('checked', false);
	}
	if(1 == $('#show_avatars').attr('data')) {
		$('#show_avatars').prop('checked', true);
	} else {
		$('#show_avatars').prop('checked', false);
	}
	
	//radio
	$('input[name=avatar_rating]').each(function(i, e){
		if($(e).val() == $('#avatar_rating').val()) {
			$(e).prop('checked', true);
	    } else {
	    	$(e).prop('checked', false); 
	    }
	});
	$('input[name=avatar_default]').each(function(i, e){
		if($(e).val() == $('#avatar_default').val()) {
			$(e).prop('checked', true);
	    } else {
	    	$(e).prop('checked', false); 
	    }
	});
	
	//select
	$('#thread_comments_depth').val($('#thread_comments_depth').attr('data'));
	$('#default_comments_page').val($('#default_comments_page').attr('data'));
	$('#comment_order').val($('#comment_order').attr('data'));
	
	form.render();
});
</script>
#end